package com.kun.kunkunmall.order.web;

import com.kun.kunkunmall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class HelloController {

    @GetMapping("/{page}.html")
    public String listPage(@PathVariable("page") String page) {
        return page;
    }


    @Autowired
    RabbitTemplate rabbitTemplate;


    @GetMapping("/createOrder")
    @ResponseBody
    public String createOrder(){
        // 创建一个订单
        OrderEntity orderEntity = new OrderEntity();
        orderEntity.setOrderSn("123123123122");

        rabbitTemplate.convertAndSend("order-event-exchange","order.create.order",orderEntity);
        return "111";
    }


}
